#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
class Solution {
public:
    string addStrings(string num1, string num2) {
        int end1 = num1.size() - 1;
        int end2 = num2.size() - 1;
        int next = 0;
        string str;
        while (end1 >= 0 || end2 >= 0)
        {
            int n1 = end1 >= 0 ? num1[end1] - '0' : 0;
            int n2 = end2 >= 0 ? num2[end2] - '0' : 0;

            int ret = n1 + n2 + next;
            next = ret / 10;
            ret = ret % 10;
            str += ('0' + ret);
            end1--;
            end2--;
        }
        if (next > 0)
            str += (next + '0');
        reverse(str.begin(), str.end());
        return str;
    }
};